#!/bin/bash

set -e

PROJECT_NAME="app-api"
BINARY="app-api"

OUTPUT_DIR=bin/
GOOS=$(go env GOOS)

#APP_NAME=${PROJECT_NAME}
APP_VERSION=$(git log -1 --oneline)
BUILD_VERSION=$(git log -1 --oneline)
BUILD_TIME=$(date "+%FT%T%z")
GIT_REVISION=$(git rev-parse --short HEAD)
GIT_BRANCH=$(git name-rev --name-only HEAD)
GO_VERSION=$(go version)
FORMAT='.exe'
FILE='.go'
#go build -o ./bin/center_server.exe ./server/center_server.go

arr=('http_server')
for item in ${arr[*]}
do
    CGO_ENABLED=0 go build -installsuffix cgo -v  \
    -ldflags "-s -X 'vconf/utils.AppName=${item}' \
                -X 'vconf/utils.AppVersion=${APP_VERSION}' \
                -X 'vconf/utils.BuildVersion=${BUILD_VERSION}' \
                -X 'vconf/utils.BuildTime=${BUILD_TIME}' \
                -X 'vconf/utils.GitRevision=${GIT_REVISION}' \
                -X 'vconf/utils.GitBranch=${GIT_BRANCH}' \
                -X 'vconf/utils.GoVersion=${GO_VERSION}'" \
    -o ./bin/${item}.exe ./main/${item}.go

done
